﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TSV.Models;
using TSV.Areas.Administration.Models;
using Pagination;
namespace TSV.Controllers
{
    public class NewsViewsController : BaseViewController
    {
        #region Variable
        private const int defaultPageSize =10;
        private List<sp_GetNewsResult> allNews = new List<sp_GetNewsResult>();
        private NewsDao newsDao = new NewsDao();
        #endregion
        //
        // GET: /NewFrontEnd/

        public NewsViewsController()
		{
			BuildProducts();
		}

        private void BuildProducts()
		{
            allNews = newsDao.GetList(null,null,null,null);
		}

        public ActionResult Index(int? page)
        {
            int currentPageIndex = page.HasValue ? page.Value : 1;
            var list = this.allNews.ToPagedList(currentPageIndex, defaultPageSize);
            if (Request.IsAjaxRequest())
                return PartialView("List", list);
            else
                return View(list);
        }

        public ActionResult Detail(string id)
        {
            New obj = newsDao.GetByID(int.Parse(id));
            return View(obj);
        }

    }
}
